import random
import json
# from . import utils
from data import utils
import pandas as pd


def create_rel_info():
    rels_infos_list = []
    persons_df = pd.read_csv('./persons.csv')
    for i in range(10000):
        rel_infos = dict(
            s_mobile=str(random.choice(persons_df['mobile'])),
            o_mobile=str(random.choice(persons_df['mobile'])),
            rel_info={
                'location_id': str(random.randint(1, 100)),
                'shaftWidth': str(random.randint(1, 10)),
                'time': utils.create_date_str(),
            }
        )
        rels_infos_list.append(rel_infos)

    with open('./rels.json', 'w') as f:
        json.dump({'data': rels_infos_list}, f, ensure_ascii=False)
    pd.DataFrame(rels_infos_list).to_csv('./rels.csv', index=False)


def create_person():
    person_list = []
    name_generater = utils.BuildName()
    mobile_generator = utils.PhoneNOGenerator()
    area_generator = utils.AreaGenerator()
    IMG_URL = 'http://121.196.107.223:8000/img/'
    for i in range(10000):
        person_info = dict(
            name=name_generater.create_name(),
            mobile=mobile_generator.phoneNORandomGenerator(),
            permanent_residence=area_generator.get_area(),
            card_id=str(i),
            gender=random.choice(['0', '1', '2']),
            age=random.randint(10, 100),
            is_vaccine=False if i // 10 == 0 else True,
            status=str(random.randint(1, 3)),
            image=IMG_URL + str(random.randint(1, 130)) + '.jpeg'
        )
        person_list.append(person_info)

    with open('./persons.json', 'w') as f:
        json.dump({'data': person_list}, f, ensure_ascii=False)
    pd.DataFrame(person_list).to_csv('./persons.csv', index=False)

    pass


def main():
    pass
    # create_person()
    # create_rel_info()
    # print(utils.create_date_str())


if __name__ == '__main__':
    main()
    pass
